import Vue from 'vue'

import Cookies from 'js-cookie'

import 'normalize.css/normalize.css' // a modern alternative to CSS resets

import Element from 'element-ui'
import './styles/element-variables.scss'

import '@/styles/index.scss' // global css
import '@/styles/targa.scss' // targa css

import App from './App'
import store from './store'
import router from './router'
import i18n from './language';
import auth from '@/directive/operate-perm/auth.js'
import more from '@/directive/operate-perm/more.js'
import dataV from '@jiaminghi/data-view'

import './icons' // icon
import './permission' // permission control

import * as filters from './filters' // global filters

// 自定义表格工具组件
import RightToolbar from '@/components/RightToolbar'
// 分页组件
import Pagination from '@/components/Pagination';
import DataStatus from '@/components/DataStatus/DataStatus';
import SearchBar from '@/components/SearchBar';
import AbsoluteContainer from '@/components/AbsoluteContainer';
import PageHeader from '@/components/PageHeader';
import PageMain from '@/components/PageMain';
import FixedActionBar from '@/components/FixedActionBar';

import { resetForm, handleObjectCopy, handleMenuPermission, resetJsonObject } from '@/utils/index';
import { targaMessage, targaMessageBox, ConfirmMessageBox } from '@/utils/message';

Vue.use(Element, {
  size: Cookies.get('size') || 'medium' // set element-ui default size
})

// register global utility filters
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

Vue.config.productionTip = false

// 全局方法挂载
Vue.prototype.bus = new Vue()
Vue.prototype.resetForm = resetForm
Vue.prototype.handleObjectCopy = handleObjectCopy
Vue.prototype.resetJsonObject = resetJsonObject
Vue.prototype.handleMenuPermission = handleMenuPermission
Vue.prototype.targaMessage = targaMessage
Vue.prototype.targaMessageBox = targaMessageBox
Vue.prototype.ConfirmMessageBox = ConfirmMessageBox

// 全局组件挂载
Vue.component('RightToolbar', RightToolbar)
Vue.component('Pagination', Pagination)
Vue.component('DataStatus', DataStatus)
Vue.component('SearchBar', SearchBar)
Vue.component('AbsoluteContainer', AbsoluteContainer)
Vue.component('PageHeader', PageHeader)
Vue.component('PageMain', PageMain)
Vue.component('FixedActionBar', FixedActionBar)

// 添加指令
Vue.use(auth)
Vue.use(more)
Vue.use(dataV)

var targaVue = new Vue({
  el: '#app',
  router,
  store,
  i18n,
  render: h => h(App)
})

export default targaVue
